home *** CD-ROM | disk | FTP | other *** search
- unit Nonclt;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs;
-
- type
- TNCComponentPosition = (bpLeft,bpRight);
- TNCClickState = (csUp,csDown);
-
- TNCComponent = class(TComponent)
- private
- { private declarations }
- FPosition : TNCComponentPosition;
- FWidth : integer;
- FDragBy : boolean;
- FPosLeft,FPosRight : integer;
- FParentHandle : HWnd;
- FRPP : integer;
- FBorderValid : boolean;
- FVO : integer;
- FCH : integer;
- FOnClick : TNotifyEvent;
- FOwnerActive : boolean;
- procedure SetPosition(Value : TNCComponentPosition);
- protected
- { protected declaration }
- ParentRect : TRect;
- property PosLeft : integer read FPosLeft write FPosLeft;
- property PosRight : integer read FPosRight write FPosRight;
- property ParentHandle : HWnd read FParentHandle;
- property RelativePaintPos : integer read FRPP write FRPP;
- property BorderValid : boolean read FBorderValid;
- property VerticalOffSet : integer read FVO;
- property CaptionHeight : integer read FCH;
- property ParentActive : boolean read FOwnerActive write FOwnerActive;
- public
- { public declarations }
- constructor Create(AOwner : TComponent); override;
- procedure RePaint; virtual; abstract;
- procedure MouseMove(MouseX, MouseY : integer); virtual;
- procedure LButton(ButtonState : TNCClickState); virtual;
- procedure RButton(ButtonState : TNCClickState); virtual;
- procedure LButtonDblClk; virtual;
- procedure RButtonDblClk; virtual;
- function GetPos : integer;
- function ParentRegister(Wnd : HWnd; PaintPos,
- VOffSet,CaptionHt : integer): integer;
- function IsCovered(MouseX, MouseY : integer) : boolean;
- procedure ParentState(Active : boolean); virtual;
- published
- { published declarations }
- property Position: TNCComponentPosition read FPosition write SetPosition
- default bpRight;
- property Width: integer read FWidth write FWidth;
- property DragBy : boolean read FDragBy write FDragBy default False;
- end;
-
- implementation
-
- { ---=== TNCComponent Methods ===--- }
- constructor TNCComponent.Create(AOwner : TComponent);
- begin
- inherited Create(AOwner);
- DragBy := False;
- end;
-
- procedure TNCComponent.SetPosition(Value : TNCComponentPosition);
- begin
- if FPosition <> Value then FPosition := Value;
- end;
-
- function TNCComponent.ParentRegister(Wnd : HWnd; PaintPos,
- VOffSet, CaptionHt : integer) : integer;
- begin
- FParentHandle := Wnd;
- if PaintPos = -1 then
- FBorderValid := False
- else
- begin
- FBorderValid := True;
- RelativePaintPos := PaintPos;
- end;
- FVO := VOffSet;
- FCH := CaptionHt;
- Result := width;
- end;
-
- function TNCComponent.IsCovered(MouseX,MouseY : integer) : boolean;
- begin
- Result := False;
- if (MouseX >= PosLeft) and (MouseX <= PosRight) and (MouseY > VerticalOffSet)
- and (MouseY < (CaptionHeight+VerticalOffSet)) then Result := True;
- end;
-
- function TNCComponent.GetPos : integer;
- begin
- case Position of
- bpLeft : begin
- GetPos := RelativePaintPos;
- end;
- bpRight : begin
- GetPos := (ParentRect.Right-ParentRect.Left)-
- RelativePaintPos;
- end;
- end;
- end;
-
- procedure TNCComponent.MouseMove(MouseX, MouseY : integer);
- begin
- end;
-
- procedure TNCComponent.LButton(ButtonState : TNCClickState);
- begin
- end;
-
- procedure TNCComponent.RButton(ButtonState : TNCClickState);
- begin
- end;
-
- procedure TNCComponent.LButtonDblClk;
- begin
- end;
-
- procedure TNCComponent.RButtonDblClk;
- begin
- end;
-
- procedure TNCComponent.ParentState(Active : boolean);
- begin
- ParentActive := Active;
- end;
-
- end.
-